#_*_coding:utf-8_*_
import cv2
import numpy as np
import sys
from PIL import ImageGrab

if __name__ == "__main__" :

    screenshot = ImageGrab.grab()
	img_rgb = np.array(screenshot)
	img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
	template = cv2.imread(sys.argv[1], 0)

	template_h, template_w = template.shape[:2]
 
	res = cv2.matchTemplate(img_gray, template, cv2.TM_CCOEFF_NORMED)
	threshold = float(sys.argv[2])

	loc = np.where(res >= threshold)
	if len(loc[::-1][0]) < 1:
		print(0, 0)
	else:
		print(loc[::-1][0][0]+template_w//2, loc[::-1][1][0]+template_h//2)
